package zzz.action;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import zzz.model.Order;
import zzz.service.ManagerService;
import zzz.service.OrderService;

@Controller
@RequestMapping("/ordermanage")
public class ManageOrderAction {
	@Autowired
	private ManagerService managerService;
	@RequestMapping("/manageorder")
	public String manageOrder(Map<String,List<Order>> m){
		List<Order> allOrder=managerService.getOrderList();
		System.out.println(allOrder);
		m.put("allOrder", allOrder);
		return "manager/orderManager";
	}
	
	@RequestMapping("/delOrder")
	public String delOrder(String hoId){
		System.out.println("hoId"+hoId);
		managerService.delOrder(hoId);
		return "redirect:manageorder";
	}
	
	@RequestMapping("/toOrderChange")
	public String orderChange(Map<String,Order> m,String hoId){
		Order order=managerService.getOrderByHoid(hoId);
		m.put("order", order);
		return "manager/orderManagerChange";
	}
	
	@RequestMapping("/updateOrder")
	public String updateOrder(Order order){
		System.out.println("orderManager:"+order);
		managerService.updateOrder(order);
		return "redirect:manageorder";
	}
	@RequestMapping("/orderManageAddOrder")
	public String addOrderPage() {
		return "manager/orderManageAddOrder";
	}
	
	@RequestMapping("/mgPublishNewOrder")
	public String mgPublishNewOrder(Order order){
		managerService.mgPublishNewOrder(order);
		return "redirect:manageorder";
	}
}
